import { createRouter, createWebHashHistory } from 'vue-router'
import Dashboard from '../views/Dashboard.vue'

const routes = [
  {
    path: '/',
    name: 'Dashboard',
    component: Dashboard
  },
  {
    path: '/analytics',
    name: 'Analytics',
    component: () => import('../views/Analytics.vue'),
    children: [
      {
        path: 'sales',
        name: 'SalesAnalytics',
        component: () => import('../views/analytics/Sales.vue')
      },
      {
        path: 'growth',
        name: 'GrowthAnalytics',
        component: () => import('../views/analytics/Growth.vue')
      },
      {
        path: 'performance',
        name: 'PerformanceAnalytics',
        component: () => import('../views/analytics/Performance.vue')
      }
    ]
  },
  {
    path: '/users',
    name: 'Users',
    component: () => import('../views/Users.vue'),
    children: [
      {
        path: 'list',
        name: 'UserList',
        component: () => import('../views/users/List.vue')
      },
      {
        path: 'roles',
        name: 'UserRoles',
        component: () => import('../views/users/Roles.vue')
      },
      {
        path: 'groups',
        name: 'UserGroups',
        component: () => import('../views/users/Groups.vue')
      }
    ]
  }
]

const router = createRouter({
  // 在 Tauri 中使用 hash 模式
  history: createWebHashHistory(),
  routes
})

export default router 